﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;

//typedef int(*ARR_TYPE)[3];
//typedef int(ARR_TYPE)[3];

//void printBiArray(int(*pArr)[3], int lenH, int lenW)
//void printBiArray(ARR_TYPE, int lenH, int lenW)
//void printBiArray(ARR_TYPE*, int lenH, int lenW)
void printBiArray(int pArr[3][3], int lenH, int lenW)
{
	for (int i = 0; i < lenH; ++i)
	{
		for (int j = 0; j < lenW; ++j)
		{
			printf("5.输出二维数组pArr的值*(*(pArr+i)+j)：%d\n", *(*(pArr + i) + j));//1, ... ,9
			printf("6.输出二维数组pArr的值pArr[i][j]：%d\n", pArr[i][j]);//1, ... ,9
		}
	}
}
void testTwoDimensionArray()
{
	int arr[3][3] = {
		{1,2,3},	//int (*)[3]
		{4,5,6},
		{7,8,9}		//arr+2 -->  *(*(arr+2)+1) -->  arr[2][1]
	};

	//int arr[3][3] = { 1,2,3,4,5,6,7,8,9 };
	//int arr[][3] = { 1,2,3,4,5,6,7,8,9 };

	//1.对于多维数组来说，同一维数组一样，除了sizeof对数组名取地址之外，那么数组名就是指向数组首元素的指针；
	printf("2.二维数组arr的首地址为：%s\n", typeid(arr).name());//int [3][3]
	int(*pArray)[3] = arr;

	printf("3.输出arr[1][2]的值：%d\n", arr[1][2]);//6
	printf("4.输出*(*(arr+2)+1)的值：%d\n", *(*(arr + 2) + 1));//8  arr[2][1]

	printBiArray(arr, 3, 3);

	//7.定义二维数组；
	char(*p)[3][3];
}

//main203：二维数组的定义和遍历
int main203()
{
	testTwoDimensionArray();

	system("pause");
	return EXIT_SUCCESS;
}